import sequtils, strutils

proc rot(a: char, key: int): char =
  result.inc(a.ord + key)
  if a >= 'a' and result > 'z' or a <= 'Z' and result > 'Z':
    result.dec(26)

proc rotate*(plain: string, key: int): string = 
  plain.mapIt(if it in Letters: rot(it, key) else: it).join